<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <%@include file="/WEB-INF/views/include/weixinhead.jsp" %>
    <script src="${ctxStatic}/modules/wechat/js/rip.js"></script>
</head>
<body>
<!--公务员考试-->
<div data-role="page" id="Graduate-school-exam" class="page">
    <div data-role="header" class="header header-1">公务员考试
        <span class="return-btn" onclick="javascript:history.back(-1);"><a href="" data-ajax="false" data-transition="slideup"><img src="${ctxStatic}/modules/wechat/css/images/yuanjiaojuxing25.png" alt=""></a></span>
    </div>
    <div role="main" class="content">
        <div class="account border-5">
            <div class="re-left">课程名称</div>
            <div class="re-right">
                <select id="examName" value="">
                </select>
            </div>
        </div>
        <div class="account border-6">
            <div class="re-left">课程简介</div>
            <div class="re-right"><textarea id="examContent" readonly></textarea></div>
        </div>
        <div class="account border-5">
            <div class="re-left">培训费用</div>
            <div class="re-right">
                <input id="examPrice" type="text" readonly  value="" style=" padding: 0px;">
                <div style="height: 14px;font-size:14px;color: #fd3e8b;position: absolute;right:12px;bottom: 0px;">元</div>
            </div>
        </div>
        <div class="account border-5" style="border-bottom: none;height:78px;">
            <div class="re-left">线上缴费</div>
            <div class="re-right" style="height:40px !important;margin-bottom: 12px">
                <a href="" data-ajax="false">
                    <div id="Graduate-school-zhufubao-btn">
                        <img src="${ctxStatic}/modules/wechat/css/images/icon-zhifubao.png" alt="支付宝支付">
                    </div>
                </a>
                <a href="" data-ajax="false">
                    <div id="Graduate-weixin-exam-btn">
                        <img src="${ctxStatic}/modules/wechat/css/images/icon-weixin.png" alt="微信支付">
                    </div>
                </a>
            </div>
        </div>
        <div class="account border-5" style="border-bottom: none">
            <div class="re-left">线下缴费</div>
            <div class="re-right"><label id="address" style="font-size: 14px;padding-left: 14px"></label></div>
        </div>
        <button id="Graduate-school-exam-btn" onclick="">确认</button>
    </div>
    <div class="footer">
        <p class="Consulting-phone"></p>
        <p class="Consulting-WeChat"></p>
    </div>
    <!--<div data-role="footer"></div>-->
</div>
<script>
    $(document).ready(function(){
        var servantId,payment,paymentPlace,servantName;
        /*先判断用户是否在线*/
        $.ajax({
            url: interfaceGetState,
            type: 'post',
            success: function (data) {
                if (data.status == 0) {    //已登录
                    /*是否实名*/
                    realName();
                    $.ajax({
                        url:interfaceCivilSEList+generateMixed(9),
                        type:'post',
                        success:function(data){
                            // console.log(data);
                            if(data.page.length>0){
                                for(var i=0;i<data.page.length;i++){
                                    $("#examName").append("<option value="+data.page[i].id+">"+data.page[i].servantName+"</option>");
                                    // console.log(data.page[0].servantForshort);
                                }
                                servantId=data.page[0].id;
                                payment=data.page[0].payment;
                                paymentPlace=data.page[0].unLinement;
                                servantName=data.page[0].servantName;
                                $("#examContent").val(data.page[0].servantForshort);
                                $("#examPrice").val(payment);
                                $("#address").text(paymentPlace);
                            }
                        }
                    })
                } else {    //未登录
                    if (window.sessionStorage) {
                        sessionStorage.setItem("prePage", "/f/campusinfo/civilServiceExamination");
                    }
                    alert("请先登录");
                    window.location.href = "/f/campusinfo/login"+generateMixed(9);
                    return false;
                }
            }
        })
        /*选择课程名称*/
        $("#examName").change(function(){
            $("#examContent").val('');
            $("#examPrice").val('');
            $("#address").text('');
            var id=$("#examName").val();
            servantId=id;
            $.ajax({
                url:interfaceCivilSEDetail+generateMixed(9),
                type:'post',
                data:{id:id},
                success:function(data){
                    // console.log(data);
                    if(data){
                        payment=data.page.payment;
                        paymentPlace=data.page.unLinement;
                        servantName =data.page.servantName
                        $("#examContent").val(data.page.servantForshort);
                        $("#examPrice").val(payment);
                        $("#address").text(paymentPlace);
                    }
                  }
            })
        })
        /*提交报名信息*/
        $("#Graduate-school-exam-btn").off("tap").on("tap",function(){
            /*先判断用户是否在线*/
            $.ajax({
                url: interfaceGetState,
                type: 'post',
                success: function (data) {
                    if (data.status == 0) {    //已登录
                        /*是否实名*/
                        realName();
                        if(real){   //已实名
                            $.ajax({
                                url:interfaceApplyForCivilSE+generateMixed(9),
                                type:'post',
                                data:{servantId:servantId,payment:payment,paymentMethod:3,paymentPlace:paymentPlace,status:0},
                                success:function(data){
                                    // console.log(data);
                                    if(data.success){
                                        alert(data.message);
                                        window.location="/f/campusinfo/entranceExamination"+generateMixed(9);
                                    }else{
                                        alert(data.message);
                                    }
                                }
                            })
                        }else{      //未实名
                            alert("未实名，请完善个人信息")
                        }
                    } else {    //未登录
                        if (window.sessionStorage) {
                            sessionStorage.setItem("prePage", "/f/campusinfo/civilServiceExamination");
                        }
                        alert("请先登录");
                        window.location.href = "/f/campusinfo/login"+generateMixed(9);
                        return false;
                    }
                }
            })
        })
        $("#Graduate-school-zhufubao-btn").off("tap").on("tap",function(){
            /*先判断用户是否在线*/
            $.ajax({
                url: interfaceGetState,
                type: 'post',
                success: function (data) {
                    if (data.status == 0) {    //已登录
                        /*是否实名*/
                        realName();
                        if(real){   //已实名
                            $.ajax({
                                url:interfaceAlipayCivilSE+generateMixed(9),
                                type:'post',
                                data:{servantId:servantId,payment:payment,servantName:servantName,paymentMethod:2,paymentPlace:paymentPlace,status:0},
                                success:function(data){
                                    // console.log(data);
                                    if(data.success){
                                        var src=data.campusinfoServant
                                        window.location.href="/alipay/pay"+"?orderNo="+src.orderCode;
                                    }else{
                                        alert(data.message);
                                    }
                                }
                            })
                        }else{      //未实名
                            alert("未实名，请完善个人信息")
                        }
                    } else {    //未登录
                        if (window.sessionStorage) {
                            sessionStorage.setItem("prePage", "/f/campusinfo/civilServiceExamination");
                        }
                        alert("请先登录");
                        window.location.href = "/f/campusinfo/login"+generateMixed(9);
                        return false;
                    }
                }
            })
        })
        $("#Graduate-weixin-exam-btn").off("tap").on("tap",function(){
            /*先判断用户是否在线*/
            $.ajax({
                url:interfaceGetState+generateMixed(9),
                type:'post',
                success:function (data) {
                    if(data.status==0){
                        //已登录
                        /*是否实名*/
                        realName();
                        if(real){   //已实名
                            $.ajax({
                                url:interfaceAlipayCivilSE+generateMixed(9),
                                type:'post',
                                data:{servantId:servantId,payment:payment,paymentMethod:1,servantName:servantName,paymentPlace:paymentPlace,status:0},
                                success:function(data){
                                    if(data.success){
                                        var src=data.campusinfoServant
                                        window.location.href="/alipayWeixin/pay/order"+"?orderNo="+src.orderCode;
                                    }else{
                                        alert(data.message);
                                    }
                                }
                            })
                        }else{      //未实名
                            alert("未实名，请完善个人信息")
                        }
                    }else {
                        //未登录
                        alert("请先登录");
                        if(window.sessionStorage){
                            var url=window.location.href;
                            sessionStorage.setItem("prePage",url+"?id="+id);
                        }
                        window.location.href="/f/campusinfo/login"+generateMixed(9);
                    }
                }
            });
        })
    })
</script>
</body>
</html>